﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Model.Module;
using Enterprise.Service.Module;
using Enterprise.Infrastructure;
namespace Enterprise.UI.Web.Manage.Module
{
    public partial class Create : System.Web.UI.Page
    {
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_OnClick(object sender, EventArgs e)
        {
            ModuleService ser = new ModuleService();
            ModuleEntity m = new ModuleEntity();
            m.MCODE = (string)Utility.sink(mCode.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            m.MNAME = (string)Utility.sink(mName.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            m.MIMAGE = "";
            m.MSINGLE = (int)Utility.sink(mSingle.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
            m.MURL = (string)Utility.sink(mUrl.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            m.MTARGET = (string)Utility.sink(mTarget.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            m.MPARENTID = Id;
            m.MROOTID = 0;
            if (Id != 0)
            {
                var q = ser.ModuleDisp(Id);
                if (q != null)
                {
                    if (q.MPARENTID != 0)
                    {
                        m.MROOTID = q.MROOTID;
                    }
                    else
                    {
                        m.MROOTID = Id;
                    }
                }
            }
            m.MDELETE = "0";
            m.MORDERBY = ser.GetMaxModuleOrderBy(Id) + 1;
            m.DB_Option_Action = "Insert";
            ser.ModuleExecute(m);
            Response.Redirect("Index.aspx");
            Response.End();
        }

    }
}